/**
 * 							Timer Defination
 * @brief	Timer Definaton
 * @author	chy.
 * @note
 * @comment	this file defines macros and functions used by common time module!
 */

#ifndef	_K_DRIV_TIMER_S3C2440_H_
#define	_K_DRIV_TIMER_S3C2440_H_

/** timer registers address definations */
#define	TCFG0			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000000))
#define	TCFG1			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000004))
#define	TCON			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000008))

// timer 0
#define	TCNTB0			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X5100000c))	// count buffer
#define	TCMPB0			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000010))	// compare buffer
#define	TCNTO0			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000014))	// read buffer

// timer 1
#define	TCNTB1			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000018))	// count buffer
#define	TCMPB1			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X5100001c))	// compare buffer
#define	TCNTO1			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000020))	// read buffer

// timer 2
#define	TCNTB2			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000024))	// count buffer
#define	TCMPB2			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000028))	// compare buffer
#define	TCNTO2			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X5100002c))	// read buffer

// timer 3
#define	TCNTB3			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000030))	// count buffer
#define	TCMPB3			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000034))	// compare buffer
#define	TCNTO3			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000038))	// read buffer

// timer 4
#define	TCNTB4			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X5100003c))	// count buffer
#define	TCNTO4			(*(unsigned int *)K_IO_PHYPORT2VIRPORT(0X51000040))	// read buffer

typedef enum
{
	KD_TIMER_0	= 0,
	KD_TIMER_1,
	KD_TIMER_2,
	KD_TIMER_3,
	KD_TIMER_4
}KD_TimerID;

/**
 * @BRIEF	:	Initialize Timer
 * @PARAM	:	void
 * @RETURN	:	void
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 */
void k_driv_s3c2440_timer_init(void);


/**
 * @BRIEF	:	Start Timer
 * @PARAM	:	id	timer id.
 * @PARAM	:	count_val	count value for count buffer
 * @PARAM	:	comp_val	compare value for compare buffer
 * @RETURN	:	void
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 * 			:	The timer will start in this function.
 */
void k_driv_s3c2440_timer_start(KD_TimerID id, unsigned short count_val, unsigned short comp_val);

/**
 * @BRIEF	:	Read Timer Count Value
 * @PARAM	:	id		timer id
 * @RETURN	:	count value
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 * 			:	The timer will start in this function.
 */
unsigned short	k_driv_s3c2440_timer_read_count(KD_TimerID id);

#endif	/* _K_DRIV_TIMER_S3C2440_H_ */